<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="app">
    <router-link to="/home">home</router-link>
    <router-link to="/about">about</router-link>
    <router-link to="/not-found">not found</router-link>
    <router-view></router-view>
</div>
</body>
<script src="vue.js"></script>
<script src="vue-router.min.js"></script>
<script>
    const Home = {
        template: `
        <div>
            <router-link to="/home/child1">child1</router-link>
            <router-link to="/home/child2">child2</router-link>
            <router-view></router-view>
        </div>
        `
    };
    const child1 = {
        template: `<div>I am child1</div>`,
    };
    const child2 = {
        template: `<div>I am child2</div>`,
    };
    const About = { template: '<p>about page</p>' };
    const NotFound = { template: '<p>Page not found</p>' };

    const routes = [
        {path: '/', redirect: '/home'},
        {
            path: '/home',
            component: Home,
            children: [
                {
                    path: '/home/',
                    redirect: "/home/child1",
                },
                {
                    path: '/home/child1',
                    component: child1,
                },
                {
                    path: '/home/child2',
                    component: child2,
                }
            ]},
        {path: '/about', component: About},
        {path: '/not-found', component: NotFound},
    ];

    const router = new VueRouter({
        routes: routes
    });
    new Vue({
        el: '#app',
        router: router
    })
</script>
</html>